/*
 * Copyright 2023-2085 xujin <ceo@itgrail.com>
 *
 * Licensed under the Grail License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://itgrail.com/docs?id=3&catalogId=87
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.itgrail.pilot.infrastructure.tunnel.db.dataobject;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.sql.Timestamp;

import static com.baomidou.mybatisplus.annotation.IdType.AUTO;

/**
 * @author halo codegen
 */
@TableName("t_department")
@Data
public class DepartmentDO {

    /**
     *
     */
    @TableId(value = "id", type = AUTO)
    private Integer id;

    /**
     * 名称
     */
    @TableField(value = "name")
    private String name;

    /**
     * 身份源[CREATE(create): 自建, DING_TALK(ding_talk): 钉钉, LARK(lark): 飞书, WEICHART_WORK(weichart_work): 企业微信]
     */
    @TableField(value = "identity_source")
    private String identitySource;

    /**
     * 身份源Id
     */
    @TableField(value = "identity_source_id")
    private String identitySourceId;

    /**
     * 身份源的部门唯一Id
     */
    @TableField(value = "external_id")
    private String externalId;

    /**
     * 身份源的部门父Id
     */
    @TableField(value = "external_parent_id")
    private String externalParentId;

    /**
     *
     */
    @TableField(value = "dept_manager_userids")
    private String deptManagerUserids;

    /**
     * 编码
     */
    @TableField(value = "code")
    private String code;

    /**
     * 类型[GROUP(group):集团, COMPANY(company):公司, DEPARTMENT(department):部门, UNIT(unit):单位]
     */
    @TableField(value = "type")
    private String type;

    /**
     * 上级部门Id
     */
    @TableField(value = "parent_id")
    private Integer parentId;

    /**
     * 路径枚举ID
     */
    @TableField(value = "path")
    private String path;

    /**
     * 路径显示名称
     */
    @TableField(value = "display_path")
    private String displayPath;

    /**
     * 顺序
     */
    @TableField(value = "sequence")
    private Long sequence;

    /**
     * 是否叶子节点[IS_LEAF(1): 叶子节点, NOT_LEAF(0): 非叶子节点]
     */
    @TableField(value = "leaf")
    private String leaf;

    /**
     * 激活状态[IS_ENABLED(1):启用, NOT_ENABLED(0):未启用]
     */
    @TableField(value = "enabled")
    private Integer enabled;

    /**
     * 是否展示部门报表, 0不展示 1展示
     */
    @TableField(value = "is_count")
    private Byte isCount;

    /**
     * 部门负责人id
     */
    @TableField(value = "leader_id")
    private Integer leaderId;

    /**
     * 部门层级
     */
    @TableField(value = "dept_level")
    private Integer deptLevel;

    /**
     * 部门负责人名称
     */
    @TableField(value = "leader_name")
    private String leaderName;

    /**
     * 逻辑删除标志
     */
    @TableField(value = "is_deleted")
    private String isDeleted;

    /**
     * 创建时间
     */
    @TableField(value = "create_at")
    private Timestamp createAt;

    /**
     * 更新时间
     */
    @TableField(value = "update_at")
    private Timestamp updateAt;

    /**
     * 创建人
     */
    @TableField(value = "create_by")
    private String createBy;

    /**
     * 更新人
     */
    @TableField(value = "update_by")
    private String updateBy;


    public enum IdentitySource {

        CREATE("create", "自建"),
        DING_TALK("ding_talk", "钉钉"),
        LARK("lark", "飞书"),
        WEICHART_WORK("weichart_work", "企业微信");

        private final String value;

        private final String name;

        IdentitySource(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return this.value;
        }

        public String value() {
            return this.value;
        }

        public String getName() {
            return this.name;
        }

        public static IdentitySource parseValue(String value) {
            if (value != null) {
                for (IdentitySource item : values()) {
                    if (item.value.equals(value)) {
                        return item;
                    }
                }
            }
            return null;
        }

        public static IdentitySource parseName(String name) {
            if (name != null) {
                for (IdentitySource item : values()) {
                    if (item.name.equals(name)) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum Type {
        GROUP("group", "集团"),
        COMPANY("company", "公司"),
        DEPARTMENT("department", "部门"),
        UNIT("unit", "单位");

        private final String value;

        private final String name;

        Type(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return this.value;
        }

        public String value() {
            return this.value;
        }

        public String getName() {
            return this.name;
        }

        public static Type parseValue(Integer value) {
            if (value != null) {
                for (Type item : values()) {
                    if (item.value.equals(value)) {
                        return item;
                    }
                }
            }
            return null;
        }

        public static Type parseName(String name) {
            if (name != null) {
                for (Type item : values()) {
                    if (item.name.equals(name)) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum Is_Leaf {
        IS_LEAF("1", "叶子节点"),
        NOT_LEAF("0", "非叶子节点");

        private final String value;

        private final String name;

        Is_Leaf(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return this.value;
        }

        public String value() {
            return this.value;
        }

        public String getName() {
            return this.name;
        }

        public static Is_Leaf parseValue(Integer value) {
            if (value != null) {
                for (Is_Leaf item : values()) {
                    if (item.value.equals(value)) {
                        return item;
                    }
                }
            }
            return null;
        }

        public static Is_Leaf parseName(String name) {
            if (name != null) {
                for (Is_Leaf item : values()) {
                    if (item.name.equals(name)) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum Enabled {
        IS_ENABLED(new Integer("1"), "启用"),
        NOT_ENABLED(new Integer("0"), "未启用");

        private final Integer value;

        private final String name;

        Enabled(Integer value, String name) {
            this.value = value;
            this.name = name;
        }

        public Integer getValue() {
            return this.value;
        }

        public Integer value() {
            return this.value;
        }

        public String getName() {
            return this.name;
        }

        public static Enabled parseValue(Integer value) {
            if (value != null) {
                for (Enabled item : values()) {
                    if (item.value.equals(value)) {
                        return item;
                    }
                }
            }
            return null;
        }

        public static Enabled parseName(String name) {
            if (name != null) {
                for (Enabled item : values()) {
                    if (item.name.equals(name)) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

}
